/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package PlasticSystem.impl;

import PlasticSystem.Local;
import PlasticSystem.PlasticSystemPackage;
import PlasticSystem.Remote;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.plastic.mrn.*;
import org.plastic.util.*;
import org.plastic.mrn.QoS.*;
import java.util.*;

import cn.edu.pku.sei.ra.wrapping.CommonWrapping.WrappingEObject;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.impl.WrappingEObjectImpl;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.EObjectContainmentEListForWrapping;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * <!-- begin-user-doc --> An implementation of the model object '
 * <em><b>Remote</b></em>'. <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link PlasticSystem.impl.RemoteImpl#getName <em>Name</em>}</li>
 *   <li>{@link PlasticSystem.impl.RemoteImpl#getParent <em>Parent</em>}</li>
 *   <li>{@link PlasticSystem.impl.RemoteImpl#getPotentialThreads <em>Potential Threads</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RemoteImpl extends WrappingEObjectImpl implements Remote {
	/**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
	protected static final String NAME_EDEFAULT = null;

	/**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
	protected String name = NAME_EDEFAULT;

	/**
   * The default value of the '{@link #getPotentialThreads() <em>Potential Threads</em>}' attribute.
   * <!-- begin-user-doc --> <!--
	 * end-user-doc -->
   * @see #getPotentialThreads()
   * @generated
   * @ordered
   */
	protected static final int POTENTIAL_THREADS_EDEFAULT = 0;

	/**
   * The cached value of the '{@link #getPotentialThreads() <em>Potential Threads</em>}' attribute.
   * <!-- begin-user-doc --> <!--
	 * end-user-doc -->
   * @see #getPotentialThreads()
   * @generated
   * @ordered
   */
	protected int potentialThreads = POTENTIAL_THREADS_EDEFAULT;

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	protected RemoteImpl() {
    super();
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	@Override
	protected EClass eStaticClass() {
    return PlasticSystemPackage.Literals.REMOTE;
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	public boolean isForCore(Object arg0) {
   	boolean result=true;
    if (core != null
        && (((Vector) core).get(0).equals(((Vector) arg0).get(0))))
      result = true;
    else
      result = false;
    return result;
  }

	public static final Integer INVITE = 0;

	public static final Integer JOIN = 1;

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	public List listSubCores(int featureID) {
    List result=new ArrayList();
    switch(featureID){
  
  
  
  }
    return result;
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	public EClass getChildClassMap(Object object) {
    PlasticSystemPackage pack=PlasticSystemPackage.eINSTANCE;	
  
  
  
    return null;
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	public String getName() {
        java.util.Vector core=(java.util.Vector)getCore();
        if(core==null) return name;	
        name = (String) core.get(0);
    return name; 
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	public void setName(String newName) {
    String oldName = name;
    name = newName;
        	
      java.util.Vector core=(java.util.Vector)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, PlasticSystemPackage.REMOTE__NAME, oldName, name));
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	public Local getParent() {
    if (eContainerFeatureID != PlasticSystemPackage.REMOTE__PARENT) return null;
    return (Local)eContainer();
  }

	/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetParent(Local newParent, NotificationChain msgs)
  {
    msgs = eBasicSetContainer((InternalEObject)newParent, PlasticSystemPackage.REMOTE__PARENT, msgs);
    return msgs;
  }

  /**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	public void setParent(Local newParent) {
    if (newParent != eInternalContainer() || (eContainerFeatureID != PlasticSystemPackage.REMOTE__PARENT && newParent != null))
    {
      if (EcoreUtil.isAncestor(this, newParent))
        throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
      NotificationChain msgs = null;
      if (eInternalContainer() != null)
        msgs = eBasicRemoveFromContainer(msgs);
      if (newParent != null)
        msgs = ((InternalEObject)newParent).eInverseAdd(this, PlasticSystemPackage.LOCAL__REMOTE, Local.class, msgs);
      msgs = basicSetParent(newParent, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, PlasticSystemPackage.REMOTE__PARENT, newParent, newParent));
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	public int getPotentialThreads() {
        java.util.Vector core=(java.util.Vector)getCore();
        if(core==null) return potentialThreads;	
        potentialThreads = ((Integer)core.get(3)).intValue();
    return potentialThreads; 
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	public void setPotentialThreads(int newPotentialThreads) {
    int oldPotentialThreads = potentialThreads;
    potentialThreads = newPotentialThreads;
        	
      java.util.Vector core=(java.util.Vector)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, PlasticSystemPackage.REMOTE__POTENTIAL_THREADS, oldPotentialThreads, potentialThreads));
  }

	/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case PlasticSystemPackage.REMOTE__PARENT:
        if (eInternalContainer() != null)
          msgs = eBasicRemoveFromContainer(msgs);
        return basicSetParent((Local)otherEnd, msgs);
    }
    return super.eInverseAdd(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case PlasticSystemPackage.REMOTE__PARENT:
        return basicSetParent(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs)
  {
    switch (eContainerFeatureID)
    {
      case PlasticSystemPackage.REMOTE__PARENT:
        return eInternalContainer().eInverseRemove(this, PlasticSystemPackage.LOCAL__REMOTE, Local.class, msgs);
    }
    return super.eBasicRemoveFromContainerFeature(msgs);
  }

  /**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
    switch (featureID)
    {
      case PlasticSystemPackage.REMOTE__NAME:
        return getName();
      case PlasticSystemPackage.REMOTE__PARENT:
        return getParent();
      case PlasticSystemPackage.REMOTE__POTENTIAL_THREADS:
        return new Integer(getPotentialThreads());
    }
    return super.eGet(featureID, resolve, coreType);
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	@Override
	public void eSet(int featureID, Object newValue) {
    switch (featureID)
    {
      case PlasticSystemPackage.REMOTE__NAME:
        setName((String)newValue);
        return;
      case PlasticSystemPackage.REMOTE__PARENT:
        setParent((Local)newValue);
        return;
      case PlasticSystemPackage.REMOTE__POTENTIAL_THREADS:
        setPotentialThreads(((Integer)newValue).intValue());
        return;
    }
    super.eSet(featureID, newValue);
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	@Override
	public void eUnset(int featureID) {
    switch (featureID)
    {
      case PlasticSystemPackage.REMOTE__NAME:
        setName(NAME_EDEFAULT);
        return;
      case PlasticSystemPackage.REMOTE__PARENT:
        setParent((Local)null);
        return;
      case PlasticSystemPackage.REMOTE__POTENTIAL_THREADS:
        setPotentialThreads(POTENTIAL_THREADS_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	@Override
	public boolean eIsSet(int featureID) {
    switch (featureID)
    {
      case PlasticSystemPackage.REMOTE__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case PlasticSystemPackage.REMOTE__PARENT:
        return getParent() != null;
      case PlasticSystemPackage.REMOTE__POTENTIAL_THREADS:
        return potentialThreads != POTENTIAL_THREADS_EDEFAULT;
    }
    return super.eIsSet(featureID);
  }

	/**
   * <!-- begin-user-doc --> <!-- end-user-doc -->
   * @generated
   */
	@Override
	public String toString() {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(", potentialThreads: ");
    result.append(potentialThreads);
    result.append(')');
    return result.toString();
  }

} // RemoteImpl
